﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SimpleServiceBus.Utilities.Email;

namespace SimpleServiceBus.Tests.Stubs
{
    public class TestEmailService : IEmailService
    {
        private object _threadLock = new object();
        private List<SentEmail> _sent = new List<SentEmail>();


        public string ServerName
        {
            get { throw new NotImplementedException(); }
            set { throw new NotImplementedException(); }
        }

        public int PortNumber
        {
            get { throw new NotImplementedException(); }
            set { throw new NotImplementedException(); }
        }

        public string FromAddress
        {
            get { throw new NotImplementedException(); }
            set { throw new NotImplementedException(); }
        }

        public void Send(string subject, string message, params string[] recipients)
        {
            Send(subject, message, null, null, recipients);
        }

        public void Send(string subject, string message, string fileName, byte[] file, params string[] recipients)
        {
            lock (_threadLock)
                _sent.Add(new SentEmail
                              {
                                  Subject = subject,
                                  Message = message,
                                  FileName = fileName,
                                  File = file,
                                  Recipients = recipients
                              });
        }

        public List<SentEmail> SentEmail { get { return _sent;} }
    }
    
    public class SentEmail
    {
        public string Subject { get; set; }
        public string Message { get; set; }
        public string FileName { get; set; }
        public byte[] File { get; set; }
        public string[] Recipients { get; set; }
    }
}
